home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #6 / Amiga Plus CD - 2004 - No. 06.iso / AmigaPlus / Begleitmaterial / 50Tools / Grafik / PerfectPaint / rexx / circle / Clock.rx < prev    next >
Text File  |  2001-05-05  |  5KB  |  320 lines

  1. /*     arexx Script */
  2.  
  3.     call addlib("rexxmathlib.library", 5, -30, 0)
  4.  
  5.     options results
  6.   parse ARG Port x y r b
  7.  
  8.     ADDRESS value Port
  9.  
  10.     pp_CountFrames
  11.     Total_Frame=result
  12.     if Total_Frame=0 then Total_Frame=1
  13.     Start_Frame=1
  14.     End_Frame=Total_Frame
  15.         
  16.     t=TIME(N)
  17.     Start_t=t
  18.     End_t=t
  19.  
  20.     Anim=0;Path=0;Type=0
  21.     Start_O=100;End_O=100
  22.     Start_S=r;End_S=r
  23.     Rayon=r
  24.  
  25.     R=-1
  26.  
  27. DO UNTIL R>-1
  28.  
  29.     pp_DialogInit 250 200 "*CLOCK*" 7
  30.     pp_Cycle 0 70 5 100 16 "Animation" 1 "No|Yes" Anim
  31.     pp_Cycle 1 70 35 100 16 "Path" 1 "None|Left|Right|Up|Down" Path
  32.     pp_Cycle 2 70 53 100 16 "Type" 1 "In|Out" Type
  33.     pp_Button 3 20 71 200 16 '*Frame*(*#'||Start_Frame||'->#'||End_Frame||'*)*'
  34.  
  35.     pp_Button 4 20 100 200 16 '*Time*(*'||Start_t||'*->*'||End_t||'*)*'
  36.     pp_Button 5 20 120 200 16 '*Size*(*'||Start_S||'*->*'||End_S||'*)*'
  37.     pp_Button 6 20 140 200 16 '*Opacity*(*'||Start_O||'*->*'||End_O||'*)*'
  38.     
  39.     pp_Dialog
  40.     R=result
  41.  
  42.     pp_GetDialog 0
  43.     Anim=result
  44.  
  45.     pp_GetDialog 1
  46.     Path=result
  47.  
  48.     pp_GetDialog 2
  49.     Type=result
  50.  
  51.     if R=-3 then DO
  52.         pp_DialogInit 150 80 "*FRAME*" 2
  53.             pp_Integer 0 60 5 50 16 "Start" 1 Start_Frame
  54.             pp_Integer 1 60 25 50 16 "End" 1 End_Frame
  55.         pp_Dialog
  56.         rc=result
  57.         IF rc=1 then DO
  58.             pp_GetDialog 0
  59.             Start_Frame=result
  60.  
  61.             pp_GetDialog 1
  62.             End_Frame=result
  63.  
  64.             IF End_Frame>Total_Frame THEN DO
  65.                 End_Frame=Total_Frame
  66.             END
  67.  
  68.             IF Start_Frame>End_Frame THEN DO
  69.                 Start_Frame=1
  70.             END
  71.  
  72.         END            
  73.     END
  74.  
  75.     if R=-4 then DO
  76.         if Anim=1 then DO
  77.             pp_DialogInit 150 75 "*TIME*" 2
  78.             pp_String 0 50 5 70 16 "Start" 1 10 Start_t
  79.             pp_String 1 50 25 70 16 "End" 1 10 End_t
  80.             pp_Dialog
  81.             rc=result
  82.             IF rc=1 then DO
  83.                 pp_GetDialog 0
  84.                 Start_t=result
  85.                 pp_GetDialog 1
  86.                 End_t=result        
  87.             END
  88.         END
  89.         ELSE DO
  90.             pp_DialogInit 150 55 "*TIME*" 1
  91.             pp_String 0 50 5 70 16 "Time" 1 10 Start_t
  92.             pp_Dialog
  93.             rc=result
  94.             IF rc=1 then DO
  95.                 pp_GetDialog 0
  96.                 Start_t=result
  97.                 End_t=result        
  98.             END
  99.         END            
  100.     END
  101.  
  102.     if R=-5 then DO
  103.         if Anim=1 then DO
  104.             pp_DialogInit 150 75 "*SIZE*" 2
  105.             pp_Integer 0 60 5 50 16 "Start" 1 Start_S
  106.             pp_Integer 1 60 25 50 16 "End" 1 End_S
  107.             pp_Dialog
  108.             rc=result
  109.             IF rc=1 then DO
  110.                 pp_GetDialog 0
  111.                 Start_S=result
  112.                 pp_GetDialog 1
  113.                 End_S=result        
  114.             END
  115.         END
  116.         ELSE DO
  117.             pp_DialogInit 150 55 "*SIZE*" 1
  118.             pp_Integer 0 60 5 50 16 "Size" 1 Start_S
  119.             pp_Dialog
  120.             rc=result
  121.             IF rc=1 then DO
  122.                 pp_GetDialog 0
  123.                 Start_S=result
  124.                 End_S=result        
  125.             END
  126.         END            
  127.     END
  128.  
  129.     if R=-6 then DO
  130.         if Anim=1 then DO
  131.             pp_DialogInit 150 75 "*OPACITY*" 2
  132.             pp_Integer 0 60 5 50 16 "Start" 1 Start_O
  133.             pp_Integer 1 60 25 50 16 "End" 1 End_O
  134.             pp_Dialog
  135.             rc=result
  136.             IF rc=1 then DO
  137.                 pp_GetDialog 0
  138.                 Start_O=result
  139.                 pp_GetDialog 1
  140.                 End_O=result        
  141.             END
  142.         END
  143.         ELSE DO
  144.             pp_DialogInit 150 55 "*OPACITY*" 1
  145.             pp_Integer 0 75 5 50 16 "Opacity" 1 Start_O
  146.             pp_Dialog
  147.             rc=result
  148.             IF rc=1 then DO
  149.                 pp_GetDialog 0
  150.                 Start_O=result
  151.                 End_O=result        
  152.             END
  153.         END            
  154.     END
  155. END
  156.  
  157.     if R=0 then DO
  158.         EXIT
  159.     END    
  160.  
  161.         Start_h=substr(Start_t,1,2)
  162.         End_h=substr(End_t,1,2)
  163.  
  164.         Start_m=substr(Start_t,4,2)
  165.         End_m=substr(End_t,4,2)
  166.  
  167.         Start_Time=Start_h*60+Start_m
  168.         End_Time=End_h*60+End_m
  169.  
  170.     IF Anim=0 then DO
  171.             pp_UpdateUndoBox x-rayon-5 y-rayon-5 x+rayon+5 y+rayon+5
  172.             IF Start_O<100 then DO
  173.                 pp_EffectOn
  174.                 pp_Trans Start_O
  175.                 CALL Clock(Start_h,Start_m,x,y,Start_S)
  176.                 pp_EffectOff
  177.             END
  178.             ELSE DO
  179.                 CALL Clock(Start_h,Start_m,x,y,Start_S)
  180.             END
  181.     END
  182.     ELSE DO
  183.  
  184.         pp_CountFrames
  185.         IF result<2 then do
  186.             pp_Warn 'Make*an*Anim*first.'
  187.             EXIT
  188.         END
  189.  
  190.         pp_GetWidth
  191.         W=result
  192.  
  193.         pp_GetHeight
  194.         H=result
  195.  
  196.         HX=Start_S
  197.         HY=Start_S
  198.  
  199.         Start_X=x
  200.         End_X=x
  201.         Start_Y=y
  202.         End_Y=y
  203.  
  204.         IF Path=1 then DO
  205.             IF Type=0 then DO
  206.                 Start_X=HX*-1
  207.             END
  208.             ELSE DO
  209.                 End_X=HX*-1
  210.             END
  211.         END
  212.  
  213.         IF Path=2 then DO
  214.             IF Type=0 then DO
  215.                 Start_X=W+HX
  216.             END
  217.             ELSE DO
  218.                 End_X=W+HX
  219.             END
  220.         END
  221.  
  222.         IF Path=3 then DO
  223.             IF Type=0 then DO
  224.                 Start_Y=HY*-1
  225.             END
  226.             ELSE DO
  227.                 End_Y=HY*-1
  228.             END
  229.         END
  230.  
  231.         IF Path=4 then DO
  232.             IF Type=0 then DO
  233.                 Start_Y=H+HY
  234.             END
  235.             ELSE DO
  236.                 End_Y=H+HY
  237.             END
  238.         END
  239.  
  240.         step=(End_Frame-Start_Frame)
  241.  
  242.         Step_O=(End_O-Start_O)/Step
  243.         Step_S=(End_S-Start_S)/Step
  244.         Step_X=(End_X-Start_X)/Step
  245.         Step_Y=(End_Y-Start_Y)/Step
  246.         Step_m=(End_m-Start_m)/Step
  247.         Step_h=(End_h-Start_h)/Step
  248.         Step_Time=(End_Time-Start_Time)/Step
  249.  
  250.         DO i=Start_Frame to End_Frame
  251.  
  252.             pp_GotoFrame i
  253.             r=trunc(Start_S+Step_S*(i-Start_Frame)+0.5,0)
  254.             O=trunc(Start_O+Step_O*(i-Start_Frame)+0.5,0)            
  255.             x1=trunc(Start_X+Step_X*(i-Start_Frame)+0.5,0)
  256.             y1=trunc(Start_Y+Step_Y*(i-Start_Frame)+0.5,0)
  257.             Time=trunc(Start_Time+Step_Time*(i-Start_Frame)+0.5,0)
  258.  
  259.             h=trunc(Time/60,0)
  260.             m=Time//60
  261.  
  262.             IF O<100 then DO
  263.                 pp_EffectOn
  264.                 pp_Trans O
  265.                 CALL Clock(h,m,x1,y1,r)
  266.                 pp_EffectOff
  267.             END
  268.             ELSE DO
  269.                 CALL Clock(h,m,x1,y1,r)
  270.             END
  271.  
  272.         END
  273.  
  274.         pp_GotoFrame Start_Frame
  275.     END
  276.  
  277.  
  278. Clock: PROCEDURE
  279.  
  280.     h=ARG(1)
  281.     m=ARG(2)
  282.     x=ARG(3)
  283.     y=ARG(4)
  284.     r=ARG(5)
  285.  
  286.     h=h+(m/60)
  287.  
  288.     pp_Circle x y r
  289.  
  290.     ang=((360/12)*3.14)/180
  291.     d=r-(r/8)
  292.  
  293.     DO i=0 to 360-ang by (360/12)
  294.  
  295.         a=cos(i*3.14/180) * d
  296.         b=sin(i*3.14/180) * d
  297.  
  298.         pp_line (x+a) (y-b) (x+a) (y-b)
  299.     END
  300.  
  301.  
  302.     i=h * 360/12
  303.     d=r/2
  304.     a=sin(i*3.14/180) * d
  305.     b=cos(i*3.14/180) * d
  306.     pp_line x y (x+a) (y-b)
  307.  
  308.     i=m * 360/60
  309.     d=r-(r/8)
  310.     a=sin(i*3.14/180) * d
  311.     b=cos(i*3.14/180) * d
  312.     pp_line x y (x+a) (y-b)
  313. RETURN
  314.  
  315.  
  316. EXIT
  317.  
  318.  
  319.  
  320.